<!DOCTYPE html>
<html lang="zh-TW">
    <head>
        <meta charset="utf-8">
        <title>RANDOM NUMBER</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
        <!--[if IE]><script type="text/javascript" src="http://code.google.com/p/explorercanvas/source/browse/trunk/silverlight/excanvas.js"></script><![endif]-->
        <script type="text/javascript" src="../src/rnds.min.js"></script>
        <style>
            h1 {
                text-align: center;
            }
            #mode {
                font-size: 17px;
            }
            #demo {
                width: 100%;
                height: 600px;
            }
            #demo canvas {
                width: 100%;
                height: 100%;
            }
        </style>
    </head>
    <body>
        <h1>RANDOM NUMBER DISTRIBUTION GRAPH</h1>
        <h3>mode selector：
            <select id="mode">
                <option value="rand_i">int</option>
                <option value="rand_f">float</option>
                <option value="rand_mm">0-100</option>
                <option value="rand_g">gaussian</option>
                <option value="rand_cos">cos</option>
                <option value="rand_boxmuller">box muller</option>
            </select>
            <button id="submit">確定</button>
        </h2>
        <div id="demo">
            <canvas id="rnd_demo"></canvas>
        </div>
    </body>
    <script>
        (function() {
            $(document).ready(function() {
                PRESENT._init();
                var pts = [];
                var rndFn = function(_fn) {
                    var _rnd = [];
                    var rnd_num = 500;
                    var _args = Array.prototype.slice.call(arguments);
                    _args = _args.slice(1);
                    for (var i = 0; i < rnd_num; i++) {
                        var _num_i = _fn.apply(this, _args);
                        _rnd.push(_num_i);
                    }
                    return _rnd;
                };
                $("#submit").click(function() {
                    var _val = $('#mode option:selected').val();
                    pts = [];
                    switch(_val) {
                        case ('rand_i'):
                        case ('rand_f'):
                            pts.push(rndFn(RND[_val]));
                            pts.push(rndFn(RND[_val]));
                            PRESENT[_val](pts);
                            break;
                        case ('rand_mm'):
                            rndFn(RND[_val], 0, 100, pts);
                            PRESENT[_val](pts, 0, 100);
                            break;
                        case ('rand_g'):
                        case ('rand_cos'):
                        case ('rand_boxmuller'):
                            rndFn(RND[_val], pts);
                            PRESENT[_val](pts);
                            break;
                    }
                });
                rndFn(RND.rand_i);
            });
        })();
    </script>
</html>
